#include "stdafx.h"
#include "StreamSource.h"
#include "IPCameraStreamSource.h"
#include "WebCameraStreamSource.h"

CStreamSource::CStreamSource(void)
{
	m_int_stream_input_type = STREAM_INPUT_IPCAMERA;
	m_hdl_stream_receiver = NULL;
	m_bln_isStreamReceiving = FALSE;

	m_ptr_input_device = NULL;
	m_ptr_stream_receiver = NULL;
	m_ptr_frame_buffer = NULL;

	m_int_stream_id = -1;

	InitCritical(m_cs_lockThread);
}

CStreamSource::~CStreamSource(void)
{
	DeleteCritical(m_cs_lockThread);
}

void CStreamSource::StartStreamReceiver()
{
}

void CStreamSource::StopStreamReceiver()
{
	EnterCritical(m_cs_lockThread);

	if (m_bln_isStreamReceiving)
	{
		if (m_ptr_stream_receiver)
			m_ptr_stream_receiver->Stop();

		m_bln_isStreamReceiving = FALSE;
	}

	LeaveCritical(m_cs_lockThread);
}

void CStreamSource::SetRelationship(CFrameBuffer* ptr_frame_buffer)
{
	m_ptr_frame_buffer = ptr_frame_buffer;
	ptr_frame_buffer->m_ptr_stream_source = this;
	m_int_stream_id = ptr_frame_buffer->m_int_stream_id;

	// setting value to STREAM_CONFIGURATION_INFO structure
	ptr_frame_buffer->m_stu_info.int_stream_id = m_int_stream_id;
}